package com.mynewspaper.directaction;

import com.mynewspaper.app.DirectAction;
import com.mynewspaper.app.Session;
import com.mynewspaper.components.Main;
import com.mynewspaper.entity.User;
import com.webobjects.appserver.WOActionResults;
import com.webobjects.appserver.WORequest;

public class DirectActionRegistration extends DirectAction {

	public DirectActionRegistration(WORequest request) {
		super(request);
	}
	
	public WOActionResults registrationAction() {
		Session session = (Session)this.session();
		String login = (String)this.request().formValueForKey("loginReg");
		String password = (String)this.request().formValueForKey("passReg");
		String firstName = (String)this.request().formValueForKey("firstnameReg");
		String lastName = (String)this.request().formValueForKey("lastnameReg");
		
		User user = new User(firstName, lastName, login, password);
		session.addUser(user);

		return pageWithName(Main.class.getName());
	}

}
